package com.barbarosso.video.model {
	import com.barbarosso.video.constants.VideoConst;	
	import com.barbarosso.utils.loader.AssetCollection;	
	import com.barbarosso.utils.loader.AssetLoader;	
	import com.barbarosso.utils.loader.types.AbstractAsset;	
	import com.barbarosso.utils.loader.types.ImageAsset;	
	import com.barbarosso.utils.loader.AssetEvent;
	import com.barbarosso.utils.loader.types.SwfAsset;
	
	import org.puremvc.as3.multicore.interfaces.IProxy;
	import org.puremvc.as3.multicore.patterns.proxy.Proxy;
	
	import flash.display.MovieClip;	

	/**
	 * @author barbarosso
	 */
	public class AssetProxy extends Proxy implements IProxy {
		
		public static const NAME : String = "com.barbarosso.video.model.SkinProxy";
       
       	private var _assetLoader 		: AssetLoader;
       	private var _assetCollection 	: AssetCollection;
       	
		private var _videoSkinAsset 	: AbstractAsset;
		private var _videoSkin 			: MovieClip;

       	private var _previewImageAsset 	: AbstractAsset;
		private var _previewImage 		: MovieClip;
		
		/*
		 * setters and getters methods ----------------------------------------------
		 */ 
		 
		public function set previewImage ( value : MovieClip ) : void {
			_previewImage = value ;
		}
		public function get previewImage (  ) : MovieClip {
			return _previewImage  ;
		}
		public function set videoSkin ( value : MovieClip ) : void {
			_videoSkin = value ;
		}
		public function get videoSkin (  ) : MovieClip {
			return _videoSkin  ;
		}
		
		public function AssetProxy(proxyName : String = null, data : Object = null) {
			super(proxyName, data);
			
			_assetCollection = new AssetCollection("assets");
			
			_videoSkinAsset 	= new SwfAsset("skin","bin/swf/skins/MainStryckman.swf");
			
			_previewImageAsset 	= new ImageAsset("preview","bin/images/IMG_0349.JPG.jpg");
			
			_assetCollection.addAsset(_videoSkinAsset);
			_assetCollection.addAsset(_previewImageAsset);
			
			_assetLoader = new AssetLoader(_assetCollection,true);
			_assetLoader.addEventListener(AssetEvent.COMPLETE, assetLoadedHandler);			
		}

		protected function assetLoadedHandler( event : AssetEvent ) : void {
			_videoSkin = _videoSkinAsset.getAsset() as MovieClip;
			trace("assetsLoadedHandler");
			//sendNotification(VideoConst.ASSETS_LOADED);
		}
		
	}
}
